package com.yt.base.util.json;

import com.google.gson.*;
import java.lang.reflect.Type;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;

public class SqlTimestampConverter implements JsonSerializer {

	private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

	public SqlTimestampConverter() {
	}

	public JsonElement serialize(Object src, Type type, JsonSerializationContext context) {
		return new JsonPrimitive(sdf.format((Timestamp) src));
	}

}
